package com.runjian.rundo.iot.agent.common.network.tcp.session;

import com.runjian.rundo.iot.agent.common.session.manager.BaseSessionManager;
import com.runjian.rundo.iot.agent.common.session.manager.SessionManager;

import io.netty.channel.Channel;
import lombok.RequiredArgsConstructor;

/**
 * 设备连接会话管理 默认实现
 *
 * @author LiGang
 */
@RequiredArgsConstructor
public abstract class TcpDeviceSessionManager<T extends TcpDeviceSession> extends BaseSessionManager<T> implements SessionManager<T> {

    public T get(Channel channel) {
        String channelId = channel.id().asLongText();
        return super.get(channelId);
    }

    public T remove(Channel channel) {
        String channelId = channel.id().asLongText();
        return super.remove(channelId);
    }

    public void putSession(Channel channel, T tcpDeviceSession, String... gatewayId) {
        String channelId = channel.id().asLongText();
        super.put(channelId, tcpDeviceSession, gatewayId);
    }

    /**
     * 生成session
     * 
     * @param channel 连接管道
     * @return
     */
    public T generateSession(Channel channel) {
        return null;
    }
}
